Ext.ns('TaxonTagger');
TaxonTagger.settings = function(config){

	this.generalPanel = new TaxonTagger.generalPanel();
	this.delimiterPanel = new TaxonTagger.FileSettings();
//	this.localStoragePanel= new TaxonTagger.localStoragePanel();
	
	Ext.apply(this, config, {
			width: 500
		,	height: 380
		,	resizable: false
		,	id: 'options'
		,	layout: 'accordion'
		,	plain: true
		,	hideCollapseTool: true
		,	titleCollapse: true
		,	modal: true
		,	defaults: {
				border: false
			}
		,	activeItem: 0
		,	items: [
					this.generalPanel
				,	this.delimiterPanel
	//			,	this.localStoragePanel
			]
		,	buttons: [{
					text: this.txtSaveClose
				,	scope: this
				,	handler: function(){
						this.localStore();
						this.close();
					}	
			}, {
					text: this.txtClose
				,	scope: this
				,	handler: function(){
						this.close();
					}	
			}]

	});
	
	TaxonTagger.settings.superclass.constructor.call(this, config);

};

Ext.extend(TaxonTagger.settings, Ext.Window, {

	localStore: function(){
		var t = this.generalPanel;
		var f = this.delimiterPanel;  
		var settings = {
				general: {
						nfServer: t.nameServer.value
					,	useStorage: t.checkLocal.checked
					,	primary: t.primaryCombo.value
					,	secondary: t.secondaryCombo.value
					,	nfServerName: t.nameServer.getRawValue()
				}
			,	delimiter: {
						setCsv: f.prop.getSource()
					,	setTab: f.prop.getSource()
					,	setCustom:	f.prop.getSource()
					,	csvStorage: f.fileSettingOptions.csv.checked
					,	tabStorage: f.fileSettingOptions.tab.checked
					,	customStorage: f.fileSettingOptions.custom.checked
				}
		};
		if(Config.currerntService == "TaxonTagger" ){
			Ext.getCmp('viewport').centerPanel.setTitle(this.viewportTitle + '(' + t.nameServer.getRawValue() + ')');
		}
		if(Config.currerntService == "Classification"){
			Ext.fly('headerId').dom.innerHTML = 'Classification Service ( Source: '+ t.nameServer.getRawValue() +' )';
		}
		localStorage.setItem("settings", Ext.encode(settings) );
	}
	
});